/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package obs;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.io.IOException;
import java.util.List;


/**
 *
 * @author Greg Scott
 */
public class ClassThatDoesStuff {

    public Pairing readPairing(Scanner s) {

        //Also not sure why 13 is in here?
        int[] arr = new int[9];
        for (int i = 0; i < 9; i++) {
            arr[i] = s.nextInt();
        }
        return new Pairing(arr);
    }

    public List<Pairing> loadPairings(int pool) throws IOException {
        List<Pairing> pairings = new ArrayList<Pairing>();
        
        
        Scanner s = new Scanner(new File("pool" + pool + ".txt"));
        while (s.hasNext()) {
            pairings.add(readPairing(s));
        }
        s.close();
        return pairings;
    }
    
    /**
     * 
     */
    public int[] randomiseOrder(int n) {
        ArrayList<Integer> arr = new ArrayList <Integer>();
        for(int i = 0; i < n; i++) {
            arr.add(i);
        }
        
        Collections.shuffle(arr);
        int [] finalArr = new int[n];
        for(int i = 0; i < n; i++) {
            finalArr[i] = arr.get(i);
        }
        return finalArr;
    }
            
            
    /**
     * 
     * @param pairings
     * @param out
     * @throws IOException 
     */
    public int randomiseToPool(int NUM_POOLS) {
        return (int)(Math.random() * NUM_POOLS);
    }

    
    public Pairing getPairing(int i, int pool) throws IOException {
        
        // Get which pairing this is from the right file
        List <Pairing> pairings = loadPairings(pool);
        Pairing p = pairings.get(i);
        return p;
        
        
    }

}
